<!DOCTYPE html>
<html>
    <head>
        <title>1</title>
        <style>
            .demo{
                background-color: orange;
            }
        </style>
    </head>
    <body>
      <button id="btn">add</button>
      <script type="text/javascript">
        const btn = document.getElementById('btn')
        btn.onclick= ()=>{
            const input =document.createElement('input')
            input.className='demo'
            input.value='1'
            document.body.appendChild(input)
            input.focus()//要是放在appendChild前面就无法自动获取焦点

        }
      </script>
    </body>
     

</html>
